package com.springcloud.eshop.product.controller;

import com.springcloud.eshop.entity.ProductSpecification;
import com.springcloud.eshop.product.service.ProductSpecificationService;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 * (ProductProperty)表控制层
 *
 * @author makejava
 * @since 2020-06-29 05:49:47
 */
@RestController
@RequestMapping("/productSpecification")
public class ProductSpecificationController {
    /**
     * 服务对象
     */
    @Resource
    private ProductSpecificationService productSpecificationService;

    /**
     * 通过主键查询单条数据
     *
     * @param id 主键
     * @return 单条数据
     */
    @RequestMapping("/selectOne")
    @ResponseBody
    public ProductSpecification selectOne(Long id) {
        return this.productSpecificationService.queryById(id);
    }

    /**
     * @Desc: 根据商品Id查询商品属性
     * @Param productId
     * @Return com.springcloud.eshop.entity.ProductProperty
     * @Date: 2020/7/2
     */
    @RequestMapping("/selectOneByProductId")
    @ResponseBody
    public ProductSpecification queryByProductId(Long productId) {
        return this.productSpecificationService.queryByProductId(productId);
    }

    @RequestMapping("/insert")
    @ResponseBody
    public ProductSpecification insert(ProductSpecification product) {
        return this.productSpecificationService.insert(product);
    }

    @RequestMapping("/update")
    @ResponseBody
    public ProductSpecification update(ProductSpecification product) {
        return this.productSpecificationService.update(product);
    }

    @RequestMapping("/delete")
    @ResponseBody
    public boolean deleteById(Long id) {
        return this.productSpecificationService.deleteById(id);
    }


}